import {
  PrimaryGeneratedColumn,
  CreateDateColumn,
  ManyToOne,
  OneToOne,
  JoinColumn,
  Column
} from 'typeorm'
import { EntityModel } from '@midwayjs/orm'
import { Attachment } from './attachment'
import { Ticket } from './ticket'

@EntityModel('ticket_sign')
export class TicketSign {

  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Ticket, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'ticket_id' })
  ticket: Ticket;

  @OneToOne(() => Attachment)
  @JoinColumn({ name: 'attachment_id' })
  attachment: Attachment;

  @Column({
    type: 'jsonb',
    default: [],
    comment: '上传后自动识别 docx 文档中的书签，用作插入签名'
  })
  bookmarks: string[];

  @CreateDateColumn({
    comment: '创建时间'
  })
  create_at: Date;
}